const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');

const WeatherCache = sequelize.define('WeatherCache', {
  cache_id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  city_id: {
    type: DataTypes.INTEGER,
    allowNull: false
  },
  date: {
    type: DataTypes.DATE,
    allowNull: false
  },
  temperature: {
    type: DataTypes.FLOAT,
    allowNull: false
  },
  humidity: {
    type: DataTypes.FLOAT,
    allowNull: false
  },
  wind_speed: {
    type: DataTypes.FLOAT,
    allowNull: false
  },
  air_quality: {
    type: DataTypes.STRING,
    allowNull: true
  },
  precipitation: {
    type: DataTypes.FLOAT,
    allowNull: true
  }
}, {
  timestamps: true,
  tableName: 'weather_cache' // Ensure the model maps to the correct table name
});

module.exports = WeatherCache; 